package hashMap;

/**
 * Description:
 * Author:    Dane
 * CreateTime:2024/8/23-下午2:49
 * Since  :   1.0
 * Version:   1.0
 */
public class myHashMap {
    public int maxSize;
    public EmpLink[] arr;

    public myHashMap(int maxSize) {
        this.maxSize = maxSize;
        arr = new EmpLink[maxSize];
        for (EmpLink link:arr){
            link=new EmpLink();
        }
    }

    public int function(int id){
        return id % maxSize;
    }

    public  void add(Emp emp){
        int id = function(emp.id);
        arr[id].add(emp);
    }

    public Emp findByID(int id ){
        int index = function(id);
        Emp emp = arr[index].findByID(id);
        return emp;
    }

    public void show(){
        for (EmpLink link:arr){
            link.show();
        }
    }

    public void del(int id){
        int index = function(id);
        arr[index].delByID(id);
    }







}
